package conductores;

import java.util.ArrayList;

import aima.search.framework.Successor;

public class OpDeleteConductor implements IOperator {

	@Override
	public void execute(Board board, int condO, Conductor condOri, ArrayList<Object> successors) {
		if (condOri.ruta.isEmpty()) {
			for (int n = 0; n < board.getConductores().size(); n++) {
				Conductor condN = board.getConductores().get(n);
				if (!condOri.equals(condN)) {
					Board newboard = board.clone();
					int id = condOri.identificador;
					Conductor cdesti = newboard.getConductores().get(n); 
					cdesti.queueUser(id);
					newboard.getConductores().remove(condO);
					if(cdesti.ValidarRuta()) {
						String s = "Eliminamos el conductor " + id
							+ " y lo a�adimos al conductor "
								+ condN.identificador;
						successors.add(new Successor(s, newboard));
					}
				}

			}

		}

	}
}
